package com.softline.documentsmall.service.impl;

import com.google.common.collect.Lists;
import com.softline.documentsmall.dao.DictionaryMapper;
import com.softline.documentsmall.dao.HotWordMapper;
import com.softline.documentsmall.entity.Dictionary;
import com.softline.documentsmall.entity.HotWord;
import com.softline.documentsmall.service.HotWordService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

@Service
@Slf4j
public class HotWordServiceImpl implements HotWordService {

    @Autowired
    HotWordMapper hotWordMapper;

    @Autowired
    DictionaryMapper dictionaryMapper;

    @Value(value = "${pageParams.currPage}")
    private Integer currPageCfg;

    @Value(value = "${pageParams.pageSize}")
    private Integer pageSizeCfg;

    @Override
    public boolean insertHotWord(HotWord hotWord) {
        boolean flag = true;
        try {
            hotWordMapper.insertHotWord(hotWord);
        }catch (Exception e){
            flag = false;
        }
        return flag;
    }

    @Override
    public List<Dictionary> selectWord(String language, String name, Integer currPage, Integer pageSize) {
        //分页参数,不传则使用默认值
        if(Objects.isNull(currPage)) {
            currPage = currPageCfg;
        }
        if(Objects.isNull(pageSize)) {
            pageSize = pageSizeCfg;
        }
        List<Dictionary>dictionaryList = Lists.newArrayList();
        return dictionaryList;
    }

    @Override
    public List<HotWord> selectHotWord(String language) {
        List<HotWord> hotWordList = hotWordMapper.selectHotWord(language);
        return hotWordList;
    }

}
